package com.until;

import java.util.concurrent.CountDownLatch;

public class Testcutdownlatch {
    public static void main(String[] args) {
        final CountDownLatch latch = new CountDownLatch(3);


        new Thread(new Runnable() {
            public void run() {
                try {
                    latch.await();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                System.out.println("Waiter Released");
            }
        }).start();
        new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(1000);
                    latch.countDown();
                    Thread.sleep(1000);
                    latch.countDown();
                    Thread.sleep(1000);
                    latch.countDown();

                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).start();

    }

}
